module Main (main) where

import XI.Directory.Parser
import XI.Directory.Todo
import XI.Directory.Types
import Text.ParserCombinators.Parsec.Prim
import System.IO.UTF8 (readFile, writeFile)
import Prelude hiding (readFile, writeFile)

main = do 
	s <- parseFromFile parseDir "test.dir"
	case s of
		Left err -> putStr "parse error at " >> print err
		Right x  -> do 
			writeFile "test.res" $ unlines $ 
				["-- Parse and script. Should be like source script without comments", ""] ++ scriptDir x
			case todo x of
				Left err -> putStr err >> putStr "Error with todo!"
				Right x -> 
					case scenarios x of
						Left err -> putStr err >> putStr "Error with scenarios!"
						Right x -> writeFile "test2.res" $ unlines $ 
								["-- Make an Directory objects then gather all chains and script it.", ""] ++ scriptDir x

